package com.test.p11flyweight.example02;

import java.util.HashMap;
import java.util.Map;

/**
 * 享元工厂
 */
public class ChessFlyweightFactory {

    /**
     * 享元池
     */
    private static Map<String,ChessFlyweight> map = new HashMap<String, ChessFlyweight>();


    public static ChessFlyweight getChess(String color){
        if(null != map.get(color)){
            return map.get(color);
        }

        ChessFlyweight cfw = new ConcreateChess(color);
        map.put(color,cfw);
        return cfw;
    }

}
